﻿#ifndef XVDELEGATE_H
#define XVDELEGATE_H

#include "DataView_global.h"
#include <QStyledItemDelegate>

#include <QEvent>

namespace xvs {

class DATAVIEW_EXPORT EditorDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    EditorDelegate(QObject *parent = nullptr);

    ~EditorDelegate();

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    //设置控件数据
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    //设置Model数据
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;

    //void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;

private slots:
    void slot_linkClick(bool);

    void slot_menuClick();

private:
};



class DATAVIEW_EXPORT ValueEditorDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    ValueEditorDelegate(QObject *parent = nullptr);

    ~ValueEditorDelegate();

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    //设置控件数据
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    //设置Model数据
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;

    //void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;

private slots:
    void slot_linkClick(bool);

    void slot_menuClick();

private:
};


}

#endif // XVDELEGATE_H
